package greetings

import (
	"container/list"
	"fmt"
)

//链表
func ListIntDemo() *list.List {

	_list := list.New()
	fmt.Println("_list size:", _list.Len())
	//fmt.Println("_list is :", _list)
	_list.PushBack(1)
	_list.PushBack(2)
	_list.PushBack(3)
	_list.PushBack(4)
	fmt.Println("_list size:", _list.Len())

	for i := _list.Front(); i != nil; i = i.Next() {
		fmt.Println("list is:", i.Value)
	}

	//fmt.Println(_list)
	return _list
}

//链表的元素是可以是混合元素的
func ListStringDemo() *list.List {

	_list := list.New()
	fmt.Println("_list size:", _list.Len())
	//fmt.Println("_list is :", _list)
	_list.PushBack("12345")
	_list.PushBack("12345")
	_list.PushBack("12345")
	_list.PushBack("12345")
	_list.PushBack(4)

	_list.PushFront(100)
	_list.PushFront(120)
	fmt.Println("_list size:", _list.Len())

	for i := _list.Front(); i != nil; i = i.Next() {
		fmt.Println("list is:", i.Value)
	}
	return _list
}
